package com.ruike.alisurface.utils;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;

import com.ruike.alisurface.Constant;
import com.ruike.alisurface.base.BaseAty;
import com.ruike.alisurface.ui.mainPage.MainActivity;
import com.ruike.alisurface.ui.mainPage.MainTypeActivity;
import com.ruike.alisurface.ui.mainPage.SystemStartActivity;
import com.ruike.alisurface.ui.setting.NetWorkActivity;
import com.ruike.alisurface.ui.setting.StopSellingActivity;
import com.voodoo.lib_utils.L;
import com.voodoo.lib_utils.ShareUtils;

public class BackMainUtils {

    public static void setActivity(Activity context) {
        Intent intent;
        boolean stop_sp = ShareUtils.getInstance().getBoolean(ShareKey.IS_STOP_SELLING, false); // 停止售卖

        if (stop_sp) {
            intent = new Intent(context, StopSellingActivity.class);
        } else {
            boolean net_sp = ShareUtils.getInstance().getBoolean(ShareKey.IS_NETWORK_STATUS, false); // 网络异常页
            if (net_sp && !(context instanceof SystemStartActivity)) {

                intent = new Intent(context, NetWorkActivity.class);
                context.startActivity(intent);
                context.overridePendingTransition(com.voodoo.lib_frame.R.anim.page_intent_in_anim, com.voodoo.lib_frame.R.anim.page_intent_out_anim);

                return;
            }
            if (ShareUtils.getInstance().getInt(ShareKey.IS_SHOP_TYPE, 1) == 1) {
                intent = new Intent(context, MainActivity.class);
                L.i("按货道展示   显示页面 ");
            } else {
                intent = new Intent(context, MainTypeActivity.class);
                L.i("按商品类型展示  显示页面");
            }
        }
        context.startActivity(intent);
        context.overridePendingTransition(com.voodoo.lib_frame.R.anim.page_intent_in_anim, com.voodoo.lib_frame.R.anim.page_intent_out_anim);

    }

    public static Intent setActivity(Context context) {
        Intent intent;
        if (ShareUtils.getInstance().getInt(ShareKey.IS_SHOP_TYPE, 1) == 1) {
            intent = new Intent(context, MainActivity.class);
            L.i("按货道展示   显示页面 ");
        } else {
            intent = new Intent(context, MainTypeActivity.class);
            L.i("按商品类型展示  显示页面");
        }
        return intent;
    }
}
